<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/tld/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean"%>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<link href="/WebFinalProject/css/FinalProjectCSS.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="table.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>List Exam Preparation</title>
<script type="text/javascript">
	function flyToPage(task, id) {
		document.forms[0].elements["modelExamPrep.examPrepId"].value = id;
		document.forms[0].task.value = task;
		document.forms[0].submit();
	}
	
// 	function initUpdateExamPrep(examPrepId){
// 		document.forms[0].task.value = "editExamPrep";
// 		document.forms[0].elements["modelExamPrep.examPrepId"].value = examPrepId;
// 		//alert(document.forms[0].task.value);
// 		document.forms[0].submit();
// 	}
	
	function deleteExamPrep(examPrepId,examFor){
		var cek = confirm('Are you sure want to Delete Exam Preparation - '+examPrepId+' ?');
		if(cek==true){
			document.forms[0].task.value = "deleteExamPrep";
			document.forms[0].elements["modelExamPrep.examPrepId"].value = examPrepId;
			document.forms[0].elements["modelExamPrep.examFor"].value = examFor;
			//alert(examFor);
			document.forms[0].submit();
		}
	}
	
	function goToDetail(idExamPrep){
		document.forms[0].elements["modelExamPrep.examPrepId"].value = idExamPrep;
		document.forms[0].task.value = "goToExamPrepDetail";
		document.forms[0].submit();
	}
	
	function searchByParam(selectedParam) {
		document.forms[0].elements['param_idExamPrep'].value = document.getElementById('paramIdExamPrep').value;
		document.forms[0].elements['param_className'].value = document.getElementById('paramClassName').value;
		document.forms[0].elements['param_batchName'].value = document.getElementById('paramBatchName').value;
		document.forms[0].elements['selectedParam'].value = selectedParam;
		document.forms[0].task.value = "listExamPrep";
		document.forms[0].submit();
	}
	
	function setDisplay() {
		document.getElementById('paramIdExamPrep').value = document.forms[0].elements['param_idExamPrep'].value;
		document.getElementById('paramBatchName').value = document.forms[0].elements['param_batchName'].value; 
		document.getElementById('paramClassName').value = document.forms[0].elements['param_className'].value;
		var selectedParam = document.forms[0].elements['selectedParam'].value;
		if(selectedParam==null) selectedParam = 'paramIdExamPrep';
		else if(selectedParam == '') selectedParam = 'paramIdExamPrep';
		document.getElementById(selectedParam).focus();
	}
</script>
<%
	if(session.getAttribute("result") != null){
		String message = session.getAttribute("result").toString();
		%>
			<script type="text/javascript">
				window.alert('<%=message%>');
			</script>
		<%
			session.removeAttribute("result");
	}
%>

</head>
<body onload="javascript:setDisplay();">
	<center>
		<table width="100%" class="bodyTable boxShadow">
			<!-- Header -->
			<tr>
				<td colspan="2"><%@include file="/include/Header.jsp"%></td>
			</tr>
		
			<!-- Content -->
			<tr>
				<td rowspan="2" width="200px" class="navigationBox"><%@include file="/include/Navigation.jsp"%></td>
				<td align="left" class="headerBox blueBackground">ACE Management > ACE-Examination</td>
			</tr>
			<tr>
				<td align="center" class="contentStyle" style="vertical-align: middle; padding:5px 7px;"><br>
					<html:form action="/Eclass" method="post">
						<html:hidden property="task" name="eclassForm" />
						<html:hidden property="modelExamPrep.examPrepId" name="eclassForm"/>
						<html:hidden property="modelExamPrep.batchClassId" name="eclassForm"/>
						<html:hidden property="modelExamPrep.examFor" name="eclassForm"/>
						
						<html:hidden property="param_idExamPrep" name="eclassForm" />
						<html:hidden property="param_batchName" name="eclassForm" />
						<html:hidden property="param_className" name="eclassForm" />
						<html:hidden property="selectedParam" name="eclassForm" />
						
						<%-- <h2><bean:write name="eclassForm" property="resultQuery" /></h2> --%>
						<table width="95%" align="center" border="0" class="boxShadow  example table-autosort table-autopage:10 table-stripeclass:alternate table-page-number:t1page table-page-count:t1pages table-filtered-rowcount:t1filtercount table-rowcount:t1allcount" id="t1">
							<thead>
								<tr class="headerBox formHeaderBackground">
									<th width="8%" class="formListStyle table-sortable:numeric">ID<br></th>
									<!-- <th class="table-filterable table-sortable:numeric" style="padding:5px 7px;">Batch Class Id</th> -->
									<th colspan="2" class="formListStyle table-sortable:default">
										Batch Name<br>
									</th>
									<th class="formListStyle table-sortable:default">
										Class Name<br>
									</th>
									<th class="formListStyle table-filterable table-sortable:default">Status</th>
									<th class="formListStyle table-filterable table-sortable:default">Exam For</th>
									<th colspan="2">Action</th>
								</tr>
								<tr class="headerBox">
									<th width="8%">
										<input type="text" id="paramIdExamPrep" size="4" onchange="javascript:searchByParam('paramIdExamPrep');" />
									</th>
									<th colspan="2" >
										<input type="text" id="paramBatchName"  onchange="javascript:searchByParam('paramBatchName');"/>
									</th>
									<th>
										<input type="text" id="paramClassName" size="8" onchange="javascript:searchByParam('paramClassName');"/>
									</th>
									
								</tr>
							</thead>
							<tbody>
								<logic:notEmpty name="eclassForm" property="listExamPrep">
									<logic:iterate id="listData" name="eclassForm" property="listExamPrep">
										<tr class="formListBackground">
											<td align="center" class="formListStyle">
												<bean:write name="listData" property="examPrepId" />												
											</td>
											<%-- <td align="center" style="vertical-align: middle;"><bean:write name="listData" property="batchClassId" /></td> --%>
											<td colspan="2" class="formListStyle leftAlign"><bean:write name="listData" property="batchName" /></td>
											<td class="formListStyle leftAlign"><bean:write name="listData" property="className" /></td>
<%-- 											<td align="center" class="formListStyle"><bean:write name="listData" property="startHour" /></td> --%>
<%-- 											<td align="center" class="formListStyle"><bean:write name="listData" property="endHour" /></td> --%>
<%-- 											<td align="center" class="formListStyle"><bean:write name="listData" property="duration" /> --%>
<%-- 												<logic:notEmpty name="listData" property="duration"> minute</logic:notEmpty>											  --%>
											</td>
											<td width="15%" align="center" class="formListStyle">
												<logic:equal value="1" name="listData" property="status">ACTIVE</logic:equal>
												<logic:notEqual value="1" name="listData" property="status">INACTIVE</logic:notEqual>
											</td>
											<td width="15%" align="center" class="formListStyle"><bean:write name="listData" property="examFor" /></td>
											
											<td class="formListStyle" colspan="2">
												<span>
<%-- 													<logic:equal value="Trainee" name="listData" property="examFor" > --%>
<%-- 														<logic:equal value="0" name="listData" property="isOpen"> --%>
<%-- 															<input type="button" class="buttonStyle" value="Detail" onclick="javascript:goToDetail(<bean:write name="listData" property="examPrepId"/>);"> --%>
													<img src="images/detailButton.png" title="view detail" style="cursor: pointer;" onclick="javascript:flyToPage('viewExamPrep', '<bean:write name="listData" property="examPrepId"/>');"/>&nbsp;
<%-- 														</logic:equal> --%>
<%-- 													</logic:equal> --%>
													<img src="images/editButton.png" title="edit" style="cursor: pointer;" onclick="javascript:flyToPage('editExamPrep', '<bean:write name="listData" property="examPrepId"/>');"/>
<!-- 													&nbsp; -->
<%-- 													<img src="images/deleteButton.png" title="delete" style="cursor: pointer;" onclick="javascript:deleteExamPrep('<bean:write name="listData" property="examPrepId"/>','<bean:write name="listData" property="examFor" />');"/> --%>
												</span>
											</td>
<!-- 											<td class="formListStyle"><input type="button" class="buttonStyle" value="Update" -->
<%-- 												onclick="javascript:initUpdateExamPrep(<bean:write name="listData" property="examPrepId"/>);"></td> --%>
<!-- 											<td class="formListStyle"><input type="button" class="buttonStyle" value="Delete" -->
<%-- 												onclick="javascript:deleteExamPrep('<bean:write name="listData" property="examPrepId"/>','<bean:write name="listData" property="examFor" />');"></td> --%>
										</tr>
									</logic:iterate>
								</logic:notEmpty>
								<logic:empty name="eclassForm" property="listExamPrep">
									<tr>
										<td colspan="8" align="center" style="vertical-align: middle; padding:5px 7px;">Data Not Found</td>
									</tr>
								</logic:empty>
							</tbody>
							<tfoot>
								<tr class="headerBox formHeaderBackground">
									<td colspan="2" width="10%" class="table-page:previous formListStyle leftAlign" style="cursor:pointer;">&lt;&lt; Previous</td>
									<td colspan="5" style="text-align:center; vertical-align: middle;">Page <span id="t1page"></span>&nbsp;of <span id="t1pages"></span></td>
									<td width="55px" align="right" class="table-page:next formListStyle" style="cursor:pointer;">Next &gt;&gt;</td>
								</tr>
								<tr>
									<td colspan="8" title="add new" align="center" class="greyBackground">						
										<div class="insertButtonGridStyle" onclick="javascript:flyToPage('addExamPrep');">
											<table>
												<tr>
													<td class="formListStyle"><img src="images/addButton.png"></td>
													<td class="formListStyle"><b>Add New Exam Preparation</b></td>
												</tr>
											</table>
										</div>									
									</td>
<!-- 									<td align="center" colspan="10" style="padding: 5px 7px;"><input type="button" class="buttonStyle" value="Insert" -->
<!-- 										onclick="javascript:flyToPage('addExamPrep');"></td> -->
								</tr>
<!-- 								<tr> -->
<!-- 									<td colspan="2" align="left" class="table-page:previous" style="cursor:pointer; padding:5px 7px;">&lt; &lt; Previous</td> -->
<!-- 									<td colspan="6" style="text-align:center; vertical-align: middle;">Page <span id="t1page"></span>&nbsp;of <span id="t1pages"></span></td> -->
<!-- 									<td colspan="2" align="right" class="table-page:next" style="cursor:pointer; vertical-align: middle; padding:5px 7px;">Next &gt; &gt;</td> -->
<!-- 								</tr> -->
								<tr>
									<td colspan="8" align="center" class="headerBox formHeaderBackground"><span id="t1filtercount"></span>&nbsp;of <span id="t1allcount"></span>&nbsp;rows match filter(s)</td>
								</tr>
							</tfoot>
						</table>

					</html:form><br><br>
				</td>
			</tr>
			
			<!-- Footer -->
			<tr>
				<td align="center" colspan="2" class="headerBox blueBackground">&copy; OME. 2013. All Rights Reserved.</td>
			</tr>
		</table>
	</center>	
</body>
</html>